ROOT_PATH=..
LIB_PATH=$(ROOT_PATH)/lib
BIN_PATH=$(ROOT_PATH)/bin
CP=/bin/cp -f
RM=/bin/rm -f
MV=/bin/mv -f
MKDIR=/bin/mkdir -p
CC=g++ -g3
LIBS := thrift_goblin_sqs_queue thrift goblin
INCLUDES=-I$(ROOT_PATH)/include -I$(ROOT_PATH)/include/thrift -I/usr/local/include/thrift
CXXFILES=goblin_sqs_queue_center.cc goblin_sqs_queue.cc goblin_sqs_queue_disk_sync_thread.cc
OBJS=$(CXXFILES:.cc=.o)
TARGET=$(ROOT_PATH)/bin/goblin_sqs
TARGET2=$(ROOT_PATH)/bin/goblin_sqs_client
all: preexec $(TARGET) $(TARGET2) afterexec

$(TARGET): $(OBJS) server.cc
	$(CC) -c $(INCLUDES) server.cc -o server.o
	$(CC) $(OBJS) server.o $(addprefix -L,$(LIB_PATH)) $(addprefix -l,$(LIBS)) -o $(TARGET)

$(TARGET2): $(OBJS) client.cc
	$(CC) -c $(INCLUDES) client.cc -o client.o
	$(CC) $(OBJS) client.o $(addprefix -L,$(LIB_PATH)) $(addprefix -l,$(LIBS)) -o $(TARGET2)

.SUFFIXES: .o .cc
.cc.o:
	$(CC) -c $(INCLUDES) $< -o $@

.PHONY: preexec
preexec:

.PHONY: afterexec
afterexec:
	$(RM) *~ *.swp

.PHONY: clean
clean:
	$(RM) *.o $(TARGET) $(TARGET2)
